/**
 * 
 */
package com.fwzc.giuseppe.activity;

import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.android.volley.toolbox.NetworkImageView;
import com.fwzc.giuseppe.R;
import com.fwzc.giuseppe.base.BaseActivity;
import com.fwzc.giuseppe.util.BitmapUtils;
import com.fwzc.giuseppe.util.VolleyHelper;

/**
 * 
 * 类名称：InformationActivity 类描述： 创建人：何琳 创建时间：2015年8月14日 上午10:50:04
 * 
 * @version
 * 
 */
public class InformationActivity extends BaseActivity implements
		OnClickListener {

	private NetworkImageView user_head;// 用户头像
	private RelativeLayout info_sex, info_height, info_weight, info_birthday,
			info_school, info_class;
	private TextView sex, height, weight, birthday, school, classes;

	public static final int UPDATE_SEX_TAG = 1001;
	public static final int UPDATE_HEIGHT_TAG = 1002;
	public static final int UPDATE_WEIGHT_TAG = 1003;
	public static final int UPDATE_BIRTHDAY_TAG = 1004;
	public static final int UPDATE_SCHOOL_TAG = 1005;
	public static final int UPDATE_CLASS_TAG = 1006;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_personal_info);

		initBar();
		initView();
		initData();
	}

	private void initView() {
		user_head = (NetworkImageView) findViewById(R.id.userhead);
		info_sex = (RelativeLayout) findViewById(R.id.info_sex);
		info_height = (RelativeLayout) findViewById(R.id.info_height);
		info_weight = (RelativeLayout) findViewById(R.id.info_weight);
		info_birthday = (RelativeLayout) findViewById(R.id.info_birthday);
		info_school = (RelativeLayout) findViewById(R.id.info_school);
		info_class = (RelativeLayout) findViewById(R.id.info_class);

		sex = (TextView) findViewById(R.id.tv_sex);
		height = (TextView) findViewById(R.id.tv_height);
		weight = (TextView) findViewById(R.id.tv_weight);
		birthday = (TextView) findViewById(R.id.tv_birthday);
		school = (TextView) findViewById(R.id.tv_school);
		classes = (TextView) findViewById(R.id.tv_classes);

		info_sex.setOnClickListener(this);
		info_height.setOnClickListener(this);
		info_weight.setOnClickListener(this);
		info_birthday.setOnClickListener(this);
		info_school.setOnClickListener(this);
		info_class.setOnClickListener(this);

	}

	private void initData() {
		actionbar_side_name.setText("个人信息");
		iv_actionbar_side_left.setVisibility(View.VISIBLE);
		tv_actionbar_side_right.setVisibility(View.VISIBLE);
		tv_actionbar_side_right.setText("切换账号");
		tv_actionbar_side_right.setTextColor(getResources().getColor(
				R.color.black_56));
		user_head
				.setIndirectBitmapListener(new NetworkImageView.IndirectBitmapListener() {
					@Override
					public Bitmap indirectBitmap(Bitmap bitmap) {
						if (bitmap != null) {
							return BitmapUtils.toRoundBitmap(bitmap);
						}
						return null;
					}

				});
		user_head
				.setImageUrl(
						"http://www.qq1234.org/uploads/allimg/141120/3_11201355222B8.jpg",
						VolleyHelper.getInstance(this).getImageLoader());
		iv_actionbar_side_left.setOnClickListener(this);
		tv_actionbar_side_right.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		if (v == info_sex) {
			// Intent sexIntent = new Intent(this,
			// UpdateSexualityActivity.class);
			// sexIntent.putExtra("sexuality_title", "性别");
			// sexIntent.putExtra("sexuality_value", sex.getText().toString()
			// .trim());
			// startActivityForResult(sexIntent,
			// InformationActivity.UPDATE_SEX_TAG);
		} else if (v == info_height) {

		} else if (v == info_weight) {

		} else if (v == info_birthday) {

		} else if (v == info_school) {

		} else if (v == info_class) {

		} else if (v == tv_actionbar_side_right) {
			Intent intent = new Intent(this, SwitchAccountsActivity.class);
			startActivity(intent);
		} else if (v == iv_actionbar_side_left) {
			finish();
		}

	}

}
